package org.oims.simpleserver.entities.results;

import org.oims.simpleserver.exceptions.HttpReturnResultInvalidException;

public class ErrorResult extends SimpleResult {
    private String msg;

    public ErrorResult(String msg) {
        super(1);
        this.msg = msg;
    }

    public ErrorResult(int code, String msg) {
        super(code);
        if(code != 0){
            this.msg = msg;
            return;
        }
        throw new HttpReturnResultInvalidException("code '0' when error appeared is invalid.");
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "{\"code\":" + this.code + ",\"msg\":\"" + this.msg + "\"}";
    }
}
